<?php
/**
 * Created by PhpStorm.
 * User: Sky
 * Date: 2017/8/1
 * Time: 上午11:41
 */

$web = \yii\helpers\Url::base();
?>
<script type="text/javascript" src="<?= $web ?>/js/jcrop/jcrop.js"></script>
<script type="text/javascript" src="<?= $web ?>/js/jcrop/jcrop.single.js"></script>
<script type="text/javascript">
    $(function () {
        $("#inputIndustryType").change(function () {
            $("#industryType").val($(this).val());
        });

    });

    function clickFile() {
        $("#uploadImg").click();
    }
</script>
<iframe id="ad_detail_partial_form_target" name="ad_detail_partial_form_target" style="display: none"></iframe>
<form id="ad_detail_partial_form" enctype="multipart/form-data" method="post" action="ad-save-handler"
      target="ad_detail_partial_form_target">
    <input type="hidden" id="hiddenId" name="hiddenId" value="<?= isset($item) ? $item['id'] : '' ?>">
    <div class="form-horizontal">
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">行业类型：</label>
            <div class="col-lg-9">
                <input type="hidden" id="industryType" name="industryType"
                       value="<?= isset($item) ? $item['industry_type_id'] : '' ?>">
                <select class="form-control" id="inputIndustryType">
                    <?php
                    foreach ($industryItems as $industryItem) {
                        if ($item != null && $industryItem['id'] == $item['industry_type_id']) {
                            ?>
                            <option value="<?= $industryItem['id'] ?>"
                                    data-is-special="<?= $industryItem['is_special'] ?>"
                                    selected><?= $industryItem['name'] ?></option>
                            <?php
                        } else {
                            ?>
                            <option value="<?= $industryItem['id'] ?>"
                                    data-is-special="<?= $industryItem['is_special'] ?>"><?= $industryItem['name'] ?></option>
                            <?php
                        }
                        ?>
                        <?php
                    }
                    ?>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">标题：</label>
            <div class="col-lg-9">
                <input type="text" class="form-control" id="inputTitle" name="inputTitle"
                       value="<?= $item == null ? '' : $item['title'] ?>"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">内容：</label>
            <div class="col-lg-9">
                <input type="text" class="form-control" id="inputContent" name="inputContent"
                       value="<?= $item == null ? '' : $item['content'] ?>"/>
            </div>
        </div>
        <!--上传广告展示图Begin -->
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">广告展示图：</label>
            <div class="col-lg-9">
                <div class="uploadImg" style="display: none;">
                    <input class="upload-img-box" type="file" onchange="previewSingleChange(this,1,1)"
                           name="uploadImg" id="uploadImg">
                </div>
                <a href="javascript:clickFile()" class="btn btn-warning">选择图片</a>
            </div>
        </div>
        <div class="form-group">
            <div class="col-lg-12">
                <label class="col-lg-3 col-sm-3 control-label"></label>
                <div class="col-lg-9">
                    <div id="imgSingle_Sure">
                        <div>
                            <input type="hidden" id="show_image_id" name="show_image_id"
                                   value="<?= isset($item['show_image']) ? $item['show_image']['id'] : '' ?>">
                            <?php if (isset($item['show_image'])): ?>
                                <img src="<?= $item['show_image']['url'] ?>" style="width: 200px">
                            <?php endif ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--上传广告展示图End -->

        <!--上传广告详情图Begin-->
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">广告详情图：</label>
            <div class="col-lg-9">
                <div class="upload-img">
                    <div class="uploadImg manyImg" style="float: left">
                        <div class="btn btn-warning uploadImgBtn" onclick="uploadMulImages(this)"
                             style="background-color: #fc8530;color: white">
                            选择图片
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="product-mod col-lg-10">
            <div class="col-lg-12">
                <label class="col-lg-3 col-sm-3 control-label"></label>
                <div class="col-lg-9">
                    <div id="Img_sure">
                        <?php if (isset($item['detail_images'])) {
                            foreach ($item['detail_images'] as $detail_image): ?>
                                <div class="tag-img-item upload-img-show">
                                    <input type="hidden" value="<?= $detail_image['id'] ?>" name="detail_images_ids[]">
                                    <span class="tag-img">
                                    <img src="<?= $detail_image['url'] ?>" style="width: 200px; height: 200px"/>
                                                                </span>
                                    <div class="del-icon" onclick="deleteImage(this)"></div>
                                </div>
                            <?php endforeach;
                        } ?>
                    </div>
                </div>
            </div>
        </div>
        <!--上传广告详情图End -->
    </div>
</form>
